function orderMenu(name){
    return new Promise(function(reslove,reject){
        let menu = name.order()
        setTimeout(function(){
          reslove(menu)
        },1000)
     })
   }
   
function record(menu){
     let jilu = server.complete(menu)
     return new Promise(function(reslove,reject){
        reslove(jilu)
     })
   }
   
function talk(menu){
    let jieshou = server.tongzhiCooker(menu)
    return new Promise(function(reslove,reject){
    reslove(jieshou)
    })
}

function cook(menu){
    let yanTime = 0
    let food = ''
    for(let i=0;i<menu.length;i++){
      yanTime += menu[i].time
      setTimeout(function(){
        food = cooker.complete(menu[i])
        console.log(food)
        serverFood(food).then(res=>{
            console.log(res)
        })
      },yanTime*1000)
    }
}

function serverFood(food){
    let serFood = server.complete(food)
    console.log('服务员已经将',serFood, '送给客人')
    return new Promise(function(reslove,reject){
     console.log(serFood)
     reslove(serFood)
    })
}

function eat(name,serFood){
    let eat =  name.eat(serFood)
    return new Promise(function(reslove,reject){
    reslove(eat)
    })
}
function shopping(name){
    return new Promise(function(reslove,reject){
        name.paymoney()
    })
}
for(let i = 0;i<queue.gukeArray.length;i++){
    console.log(queue.gukeArray[i])
    orderMenu(queue.gukeArray[i]).then(record).then(talk).then(cook)
}

// .then(serverFood).then(eat).then(shopping)
   